<template>
  <div id="amis-render-box" ref="box"></div>
</template>
  <script>
let amis = window.amisRequire("amis/embed");
export default {
  name: "AmisRender",
  props: {
    schema: {
      type: Object,
    },
    data: {
      type: Object,
    },
  },
  data() {
    return {};
  },
  methods: {
    renderAmis() {
      console.log(this.schema, "schema");
      amis.embed(
        this.$refs.box,
        this.schema,
        {
          data: {
            ...this.data,
          },
        },
        {
          tracker: (eventTrack, props) => {
            console.log("触发改变元素", eventTrack, props);
            this.$emit("changeProperties1", eventTrack);
            // window.changeProperties(eventTrack)
          },
        }
      );
    },
  },
  mounted() {
    this.renderAmis();
  },
  watch: {
    schema(value) {
      console.log(value, "schema变化了");
      this.schema = value;
      this.renderAmis();
    },
    data(value) {
      console.log("数据变化了");
      this.data = value;
      this.renderAmis();
    },
  },
};
</script>
  <style scoped>
</style>
  